/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Engine2D.geometry;

import Engine2D.math.Matrix3f;
import Engine2D.math.Vector2f;
import Engine2D.math.Vector2i;
import java.io.Serializable;

/**
 *
 * @author Garys
 */
public abstract class Shape implements Serializable {

    /**
     * 
     */
    protected float points[];
    /**
     * 
     */
    protected float x;
    /**
     * 
     */
    protected float y;
    /**
     * 
     */
    protected Vector2f translation;
    /**
     * 
     */
    protected float maxX;
    /**
     * 
     */
    protected float maxY;
    /**
     * 
     */
    protected float minX;
    /**
     * 
     */
    protected float minY;
    /**
     * 
     */
    protected float rotation;
    /**
     * 
     */
    protected float scale;
    private Matrix3f localTransform;

    /**
     * 
     */
    public Shape() {
    }

    /**
     * 
     * @param x
     * @param y
     */
    public void setLocation(float x, float y) {

        this.x = x;
        this.y = y;

    }

    /**
     * 
     * @param transform
     * @return
     */
    public abstract Shape transform(Transform transform);

    /**
     * 
     */
    protected abstract void createPoints();

    /**
     * 
     * @param loaction
     */
    public void setLocation(Vector2i loaction){
        this.x = loaction.getX();
        this.y = loaction.getY();
    }
            
    /**
     * 
     * @return
     */
    public float[] getPoints() {
        checkPoints();
        return points;
    }

    /**
     * 
     */
    public void checkPoints() {
        createPoints();

    }

    /**
     * 
     * @return
     */
    public boolean closed() {
        return true;
    }

    /**
     * 
     * @param shape
     * @return
     */
    public boolean intersects(Shape shape) {

        return false;
    }

    /**
     * 
     * @param shape
     * @return
     */
    public boolean contains(Shape shape) {

        if (shape.intersects(this)) {
            return true;
        }

        return false;

    }

    /**
     * 
     * @return
     */
    public float getMaxX() {
        return maxX;
    }

    /**
     * 
     * @param maxX
     */
    public void setMaxX(float maxX) {
        this.maxX = maxX;
    }

    /**
     * 
     * @return
     */
    public float getMaxY() {
        return maxY;
    }

    /**
     * 
     * @param maxY
     */
    public void setMaxY(float maxY) {
        this.maxY = maxY;
    }

    /**
     * 
     * @return
     */
    public float getMinX() {
        return minX;
    }

    /**
     * 
     * @param minX
     */
    public void setMinX(float minX) {
        this.minX = minX;
    }

    /**
     * 
     * @return
     */
    public float getMinY() {
        return minY;
    }

    /**
     * 
     * @param minY
     */
    public void setMinY(float minY) {
        this.minY = minY;
    }

    /**
     * 
     * @return
     */
    public float getX() {
        return x;
    }

    /**
     * 
     * @param x
     */
    public void setX(float x) {
        this.x = x;
    }

    /**
     * 
     * @return
     */
    public float getY() {
        return y;
    }

    /**
     * 
     * @param y
     */
    public void setY(float y) {
        this.y = y;
    }

    /**
     * 
     * @return
     */
    public int getPointsCount() {
        return points.length;
    }

    
    /**
     * 
     * @param matrix3f
     */
    public void transform(Matrix3f matrix3f){
        rotation = 0.0f;
        
        Matrix3f scaleMatrix = new Matrix3f(null);
        scaleMatrix.transpose();
	scaleMatrix.scale(1.0f );
        
        Matrix3f rotationMatrix = new Matrix3f(null);
        rotationMatrix.transpose();
	rotationMatrix.rotateZ(rotation);
        
        
        Matrix3f translationMatrix = new Matrix3f(null);
        rotationMatrix.transpose();
	translationMatrix.translate(translation);
        
        
        localTransform = scaleMatrix.multiplyMatrix3f(rotationMatrix.multiplyMatrix3f(translationMatrix));
        
        
        
    }

    public void render(int x, int y) {
    }
    
}
